from .MouseListener import MouseListener
import time


class MouseDragListener(MouseListener):
    def __init__(self, callback=None):
        super(MouseDragListener, self).__init__(callback)

    def callback(self, x, y, button, pressed):
        if pressed:
            self.pressTime = time.time() * 1000  # 毫秒级时间戳
            self.pressX = int(x)
            self.pressY = int(y)
        else:
            currentTime = time.time() * 1000  # 毫秒级时间戳
            self._callback(self.pressX, self.pressY, int(x), int(y), int(currentTime - self.pressTime), button)
            for window in self._maskWindows:
                window.deleteLater()

            return False
